package com.lanxiao.cloud.modules.dict.application;

import com.lanxiao.cloud.modules.dict.application.assembler.DictTypeAssembler;
import com.lanxiao.cloud.modules.dict.application.dto.DictTypeCmdAdd;
import com.lanxiao.cloud.modules.dict.application.dto.DictTypeCmdUpdate;
import com.lanxiao.cloud.modules.dict.domain.service.IDictTypeService;
import org.springframework.stereotype.Component;

/**
 * @author ：qiaoliang
 * @date ：2021-09-26
 */
@Component
public class DictTypeCmdManager {

  private final IDictTypeService dictTypeService;
  private final DictTypeAssembler dictTypeAssembler;

  public DictTypeCmdManager(
      IDictTypeService dictTypeService,
      DictTypeAssembler dictTypeAssembler) {
    this.dictTypeService = dictTypeService;
    this.dictTypeAssembler = dictTypeAssembler;
  }

  public void save(DictTypeCmdAdd cmdAdd) {
    dictTypeService.saveDictType(dictTypeAssembler.toDictType(cmdAdd));
  }

  public void update(Long id, DictTypeCmdUpdate cmdUpdate) {
    dictTypeService.updateDictType(dictTypeAssembler.toDictType(id, cmdUpdate));
  }

  public void delete(Long id) {
    dictTypeService.delete(id);
  }

}
